package com.study.dao;

import com.study.entity.BusReceiverEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.awt.print.Book;
import java.util.List;

@Repository
public interface BusReceiverDao extends JpaRepository<BusReceiverEntity, Long> {


    BusReceiverEntity findByName(String name);

    BusReceiverEntity findByNameAndAddress(String name,String address);

    @Transactional
    @Query(value = "update BusReceiverEntity p set p.name = ?1")
    @Modifying
    Integer updateName(String name);

/*  @Query("SELECT r FROM BusReceiverEntity r where r.name = ?1")
   // @Modifying
    BusReceiverEntity findByName(String name);*/

    @Query(value = "select b from BusReceiverEntity b where b.name like %:name%")
    List<BusReceiverEntity> findByNameMatch(@Param("name") String name);

}

